package bucket

import (
	"gitee.com/kordar/bucket/inject"
	"github.com/gin-gonic/gin"
	digstarter "github.com/kordar/dig-starter"
	ginsysstarter "github.com/kordar/ginsys-starter"
	middleware2 "github.com/kordar/ginsys/middleware"
	"go.uber.org/dig"
)

func routerProvider() {
	digstarter.ProvideE(func() (func(router *gin.Engine), error) {
		return Router, nil
	}, dig.Group(ginsysstarter.RouterIocGroup.Value()))
}

func Router(router *gin.Engine) {
	group := router.Group("/")
	digstarter.InvokeE(func(p inject.RouterParams) {
		group.Use(middleware2.RecoveryMiddleware())
		{
			router.POST("/bucket/detail/tree", p.BucketCtrl.Tree)
			router.POST("/bucket/detail/list", p.BucketCtrl.List)
			router.POST("/bucket/detail/del", p.BucketCtrl.Del)
			router.POST("/bucket/detail/download", p.BucketCtrl.Download)
			router.POST("/bucket/detail/rename", p.BucketCtrl.Rename)
			router.POST("/bucket/detail/cut", p.BucketCtrl.Cut)
			router.POST("/bucket/detail/copy", p.BucketCtrl.Copy)
			router.POST("/bucket/detail/upload", p.BucketCtrl.Upload)
		}
	})
}
